home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / dialer.pas < prev    next >
Pascal/Delphi Source File  |  1984-12-03  |  3KB  |  108 lines

  1. program dial;
  2.  
  3. {This program is written using Turbo Pascal.  It accepts user input to
  4. dial the Hayes SmartModem 1200.  MS-DOS interrupts are used for RS232
  5. communications, so even though this was written on a Tandy 2k, it shoul
  6. work in the IBM and the host of compatables.  If you have trouble
  7. communicating with the serial port, check and change as needed the
  8. value assigned to DL in talk.  It selects the COM port which runs the modem}
  9.  
  10. {initialize for MS DOS interrupt call}
  11. type
  12.      regipak = record ax,bx,cx,dx,bp,di,ds,es,flags:integer;
  13.      end;
  14.  
  15. var
  16.     dm:byte;
  17.     mypak: regipak;
  18.     ah,al,bh,bl,ch,cl,dh,dl,bph,bpl,dih,dil,dsh,dsl: byte;
  19.     cx,len,ct:integer;
  20.     ir:byte;
  21.     dialit,LAST,NUMBER,personal,prefix:string[40];
  22.     dummy,digit:char;
  23.  
  24. procedure talk;
  25. {Send characters to the modem}
  26. begin
  27.      with mypak do
  28.      begin
  29.      ax := ah shl 8 + al;
  30.      dx := dh shl 8 + dl;
  31.      intr($14,mypak);
  32.      end;
  33. end;
  34.  
  35. procedure send_line;
  36. {Break the number apart and TALK to the modem}
  37. begin
  38.     NUMBER:=CONCAT(prefix,DIALIt,chr(13));
  39.     len:=length(number);
  40.     ct:=1;
  41.       while ct<=len do
  42.           begin
  43.           digit:=copy(number,ct,1);
  44.           al:=ord(digit);
  45.           ah:=1;
  46.           dl:=0;
  47.           talk;
  48.           ct:=ct+1;
  49.        end;
  50. end;
  51.  
  52. procedure setup;
  53. {set communications parameters}
  54. begin
  55.      ah:=0;
  56.      dl:=0;
  57.      al:=131;
  58.      talk;
  59.      ah:=4;
  60.      dl:=0;
  61.      talk;
  62. end;
  63.  
  64. procedure hangup;
  65. {What else, but hang up the modem}
  66. begin
  67.     writeln('Hit any key to hang up modem');
  68.     read(dummy);
  69.     dialit:='h0';
  70.     send_line;
  71. end;
  72.  
  73.  
  74. PROCEDURE MAIN;
  75. {Get the number to dial or special commands}
  76. begin
  77.      setup;
  78.            writeln('');
  79.            write('Number to Dial ( . = quit  [enter] = last number): ');
  80.            readln(dialit);
  81.               if dialit='' then
  82.               begin
  83.               dialit:=last;
  84.               end;
  85.            LAST:=DIALIT;
  86.      if last<>'.' then
  87.      begin
  88. write ('Dialing ');
  89. writeln(dialit);
  90.      send_line;
  91.      hangup;
  92.      end;
  93. end;
  94.  
  95. BEGIN
  96. {Get and store the prefix code and get down to business}
  97. writeln('Enter personal dialing code  (MCI access etc) or [enter] for none');
  98. writeln('This code remains active for the complete dialing session');
  99. readln(personal);
  100. prefix:=concat('ATDT',personal);
  101. clrscr;
  102.      WHILE LAST<>'.' do
  103.      begin
  104.      main;
  105.      end;
  106. last:='ddd';
  107. end.
  108.